/*
CREDITS:
Idea base - DrDoctor

Sprites:
Missile base - Scuba Steve (Action Doom)
Weapon - ID Software (Rage), Sinael (Rip), Zrrion the Insect (Touchup)
Pickup by me!

Sounds:
Chaingun missile fire, Chaingun up sound - EA (C&C3)
Chaingun fire - Black Legion Development (Tremulous)

Let's take the idea of Matryoshka... and weaponize it!
*/

actor Matryoshka : DoomWeapon 24504
{
   //$Category Weapons
   //$Title Matryoshka
   //$Sprite MTRGX0
   Inventory.PickupSound "misc/w_pkup"
   Inventory.PickupMessage "Snagged a ''Matryoshka'' chaingun! Yep, russians came up with inception! (4)"
   Obituary "%o was slammed by %k's load of chaingun missiles."
   Weapon.UpSound "Weapons/MatryoshkaUp"
   Weapon.SelectionOrder 5
   Weapon.AmmoType "Boolet"
   Weapon.AmmoType2 "Boolet"
   Weapon.AmmoGive 40
   Weapon.AmmoUse 1
   Weapon.AmmoUse2 1
   Weapon.Kickback 75
   Weapon.SlotNumber 4
   Weapon.BobStyle InverseSmooth
   Weapon.BobSpeed 1.6
   Weapon.BobRangeY 0.6
   Weapon.BobRangeX 1.2
   Scale 0.8
   //+ALT_AMMO_OPTIONAL
   States
   {
   Ready:
     MTRG A 1 A_WeaponReady
     Loop
   Deselect:
     MTRG A 0 A_ZoomFactor(1)
     MTRG A 0 A_StopSound(5)
     MTRG A 0 A_StopSound(6)
     MTRG A 1 A_Lower
     MTRG A 0 A_Lower
     Loop
   Select:
     MTRG A 1 A_Raise
     MTRG A 0 A_Raise
     Loop
   Fire:
     TNT1 A 0 A_GunFlash
     TNT1 A 0 A_AlertMonsters
     TNT1 A 0 A_GiveInventory("BooletCasing")
	 TNT1 A 0 A_PlaySound("Weapons/MatryoshkaFire",5)
	 TNT1 A 0 A_FireCustomMissile("MatryoshkaMissile",frandom(1.0,-1.0),1,9,-2,0,frandom(1.0,-1.0))
	 MTRF A 0 A_SetAngle(Angle-0.25)
	 MTRF A 0 A_SetPitch(Pitch-0.25)
	 MTRF A 1 Bright Offset(16,48) A_ZoomFactor(0.994) //A_Jump(128,1)
	 //MTRF A 1 Bright Offset(15,47)
	 MTRF A 0 A_SetAngle(Angle-0.1)
	 MTRF A 0 A_SetPitch(Pitch-0.1)
	 MTRG B 1 Offset(14,46) A_ZoomFactor(0.997) //A_Jump(128,1)
	 //MTRG B 1 Offset(13,45)
	 MTRG C 1 Offset(12,44)A_ZoomFactor(1) //A_Jump(128,1)
	// MTRG C 1 Offset(11,43)
	 MTRG A 1 Offset(10,42) A_ReFire
	 MTRG B 1 Offset(8,40) A_ReFire
	 MTRG C 1 Offset(6,38) A_ReFire
	 MTRG A 1 Offset(5,37) A_ReFire
	 MTRG A 1 Offset(4,36) A_ReFire
	 MTRG B 1 Offset(3,35) A_ReFire
	 MTRG B 1 Offset(2,34) A_ReFire
	 MTRG C 2 Offset(1,33) A_ReFire
	 MTRG ABC 3 A_ReFire
	 Goto Ready
   AltFire:
	 TNT1 A 0 A_PlaySound("Weapons/MatryoshkaFire",5)
     TNT1 A 0 A_GunFlash
     TNT1 A 0 A_AlertMonsters
     TNT1 A 0 A_GiveInventory("BooletCasing")
	 TNT1 A 0 A_JumpIfInventory("CaliberUpgrade",1,2)
	 TNT1 A 0 A_Jump(256,2)
	 TNT1 A 0 A_PlaySound("Weapons/WolgirHEndFire",1,0.8)
	 TNT1 A 0 A_FireCustomMissile("MatryovenantMissile",frandom(1.0,-1.0),1,9,-2,0,frandom(1.0,-1.0))
	 MTRF A 0 A_SetAngle(Angle-0.25)
	 MTRF A 0 A_SetPitch(Pitch-0.25)
	 MTRF A 1 Bright Offset(16,48) A_ZoomFactor(0.994) //A_Jump(128,1)
	 //MTRF A 1 Bright Offset(15,47)
	 MTRF A 0 A_SetAngle(Angle-0.1)
	 MTRF A 0 A_SetPitch(Pitch-0.1)
	 MTRG B 1 Offset(14,46) A_ZoomFactor(0.997) //A_Jump(128,1)
	 //MTRG B 1 Offset(13,45)
	 MTRG C 1 Offset(12,44)A_ZoomFactor(1) //A_Jump(128,1)
	// MTRG C 1 Offset(11,43)
	 MTRG A 1 Offset(10,42) A_ReFire
	 MTRG B 1 Offset(8,40) A_ReFire
	 MTRG C 1 Offset(6,38) A_ReFire
	 MTRG A 1 Offset(5,37) A_ReFire
	 MTRG A 1 Offset(4,36) A_ReFire
	 MTRG B 1 Offset(3,35) A_ReFire
	 MTRG B 1 Offset(2,34) A_ReFire
	 MTRG C 2 Offset(1,33) A_ReFire
	 MTRG ABC 3 A_ReFire
	 Goto Ready
   Flash:
     TNT1 A 3 Bright A_Light1
     Goto LightDone
   Spawn:
     MTRG X -1
     Stop
   }
}